//
//  StackData.m
//  SCRAP_ObjC
//
//  Created by SRL on 10/26/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "StackData.h"
#import "Stack.h"


@implementation StackData
@synthesize stacks;

-(id) initLayout
{
	stacks = [[NSMutableArray alloc] initWithCapacity:16];
	CGPoint tlPoint = ccp(241, 563);
	float xdistsection = 386;
	float ydistsection = 243;
	float xdistlittle = 155;
	float ydistlittle = 110;
	float rot = 0;

	for(int i = 0; i < 4; i++)
	{
		for(int j = 0; j < 4; j++)
		{
			BOOL flip = FALSE;
			CGPoint point = ccp(0,0);
			char suit = 'c';
			if(i < 2 && j < 2)
			{
				suit = 's';
				point = ccp(tlPoint.x + xdistlittle * j, tlPoint.y - ydistlittle * i);
				rot = 90;
				
			}
			else if(i < 2 && j >= 2)
			{
				suit = 'd';
				point = ccp(tlPoint.x + xdistlittle * (j - 2) + xdistsection, tlPoint.y - ydistlittle * i);
				rot = 90;
			}
			else if(i >= 2 && j < 2)
			{
				suit = 'h';
				point = ccp(tlPoint.x + xdistlittle * j, tlPoint.y - ydistlittle * (i - 2) - ydistsection);
				rot = 90;
			}
			else
			{
				suit = 'c';
				point = ccp(tlPoint.x + xdistlittle * (j - 2) + xdistsection, tlPoint.y - ydistlittle * (i - 2) - ydistsection);
				rot = -90;
			}

			//CGPoint point = ccp(center.x + [stack boundingBox].size.width / 2 + x * 1.25 * [stack boundingBox].size.width * iPadScale, center.y - [stack boundingBox].size.height / 2 + y * 1.25 * [stack boundingBox].size.height * iPadScale);

			NSLog(@"Stack at: %f, %f", point.x, point.y);
			Stack *stack = [Stack initWithSuit:suit withRotation:rot];
			stack.scale = .95;
			stack.position = point;
			[stacks push:stack];
		}
	}
	return self;
}

-(id) init
{
	return self;
}

@end
